package com.cndw.kungfu.dao;

import java.util.List;

import com.cndw.dao.jade.Identity;
import com.cndw.dao.jade.annotation.DAO;
import com.cndw.dao.jade.annotation.SQL;
import com.cndw.dao.jade.annotation.SQLParam;
import com.cndw.kungfu.domain.Queue;

/**
 * 队列的数据库接口
 * @author fantadust [9677889@qq.com]
 * @date 2011-8-25 上午10:15:31
 */
@DAO
public interface QueueDao {

	
	public static final String TABLE = " kf_queue ";
	
	public static final String FIELDS = " id,playerId,type,funcType,beginTime,endTime,status,param1,param2,param3,params,intervalTime,nextExecTime,lastExecTime,execNum,title,content";
	
	/**
	 * 增加一个队列
	 * @param queue
	 * @return
	 */
	@SQL("INSERT INTO "+TABLE+" ("+FIELDS+") VALUES(:p.id,:p.playerId,:p.type,:p.funcType,:p.beginTime,:p.endTime,:p.status,:p.param1,:p.param2,:p.param3,:p.params,:p.intervalTime,:p.nextExecTime,:p.lastExecTime,:p.execNum,:p.title,:p.content)")
	public Identity insert(@SQLParam("p") Queue queue);
	
	
	@SQL("update "+TABLE+" set endTime=:p.endTime,status=:p.status,nextExecTime=:p.nextExecTime,execNum=:p.execNum,lastExecTime=:p.lastExecTime where id=:p.id ")
	public void update(@SQLParam("p") Queue queue);
	
	@SQL("select "+FIELDS+" from "+TABLE+" order by nextExecTime asc,endTime asc,id asc  ")
	public List<Queue> selectAll();
	
	@SQL("delete from "+TABLE+" where id=:1 ")
	public void delete(int id);
	
	
}
